package com.qst;
   //导入系统随机函数类
   import java.util.Random;
//导入动物城管理类
   import com.qst.biz.Zootopia;
/**
 * 游戏类
 * @author qst
 *
 */
public class Game {//对象数组模拟动物城
     public  Zootopia[] animalcity = new Zootopia[8];
    /**
     * 构造函数
     */
    public Game(){
        animalcity[0] = new Zootopia("豹警官", "吃甜甜圈", "正常");
        animalcity[1] = new Zootopia("夏奇羊", "正在演出", "正常");
        animalcity[2] = new Zootopia("水獭子", "练习瑜伽", "正常");
        animalcity[3] = new Zootopia("大先生", "出差公干", "正常");
        animalcity[4] = new Zootopia("狮市长", "打电话中", "正常");
        animalcity[5] = new Zootopia("羊副市", "正常办公", "正常");
        animalcity[6] = new Zootopia("美洲豹", "正在开车", "正常");
        animalcity[7] = new Zootopia("小尼克", "提供线索", "正常");
    }
    /**
     * 产生疯狂动物
     * @return 返回已产生疯狂动物之后的疯狂动物城
     */
    private Zootopia[] generateCrazyAnimal()
    {
        Random a1 = new Random();
        for(int i = 0; i < 1; i++)
        {
            animalcity[a1.nextInt(7)].condition = "疯狂";
            if(animalcity[7].name.equals(animalcity[a1.nextInt(7)].name) ||
                    animalcity[7].name.equals(animalcity[a1.nextInt(7)].name))
            {
                i--;  //如果2位主角疯狂，重新随机一次
            }
        }
        return animalcity;
    }
    /**
     * 开启游戏
     */
    public void start(){
        System.out.println("系统提示：游戏开始，随机生成疯狂动物！");
        System.out.println();
        System.out.println();
        //随机生成疯狂动物
        this.generateCrazyAnimal();
    }

}
